package top.leetcode;

/**
 * @Desc
 * @Author houruiyang
 * @Date 2022/12/21
 **/
public class _007 {

    public static void main(String[] args) {
        int reverse = reverse(-2147483412);
        System.out.println(reverse);
    }

    public static int reverse(int x) {
        int rev = 0;
        while (x!=0) {
            if (rev < Integer.MIN_VALUE / 10 || rev > Integer.MAX_VALUE / 10) {
                return 0;
            }
            int digit = x % 10;
            x = x /10;
            rev = rev * 10 + digit;
        }
        return rev;
    }
}
